package activity.projeto;

import org.andengine.engine.camera.hud.HUD;
import org.andengine.entity.primitive.Rectangle;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

public class ProgressBar extends HUD {
	private Rectangle mProgressRectangle;
	private int width;
	private int maxValueOfProgressBar;
	
	public ProgressBar(int pX, int pY, int pWidht, int pHeight,  ITextureRegion mProgressBarTextureRegion, VertexBufferObjectManager pVertexBufferObjectManager) {
		maxValueOfProgressBar = pWidht;
		mProgressRectangle = new Rectangle(pX, pY, pWidht, pHeight, pVertexBufferObjectManager);
		this.attachChild(this.mProgressRectangle);
	}
	
	public void setColor(int color1, int color2, int color3) {
		mProgressRectangle.setColor(color1, color2, color3);
	}
	
	public void increase(int value) {
		if ((width + value) >= maxValueOfProgressBar) {
			mProgressRectangle.setWidth(maxValueOfProgressBar);
		} else {
			mProgressRectangle.setWidth(width + value);
		}
	}
	
	public void decrease(int value) {
		if ((width - value) <= 0) {
			mProgressRectangle.setWidth(0);
		} else {
			mProgressRectangle.setWidth(this.width - value);
		}
	}
}
